//
//  AppDelegate.m
//  Delicious
//
//  Created by gy on 16/5/5.
//  Copyright © 2016年 gy. All rights reserved.
//

#import "AppDelegate.h"
#import "LeftViewController.h"
#import "drawerViewController.h"
#import "UIViewController+RECurtainViewController.h"
#import "FoodsViewController.h"
#import "ChuanDishPictureViewController.h"
#import "ChuanDishViewController.h"
#import "ZheDishPictureViewController.h"
#import "ZheDishViewController.h"
#import "LuDishPictureViewController.h"
#import "LuDishViewController.h"
#import "SuDishPictureViewController.h"
#import "SuDishViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    ChuanDishViewController *sencondVC2 = [[ChuanDishViewController alloc]init];
    UINavigationController *nag2 = [[UINavigationController alloc]initWithRootViewController:sencondVC2];
    UIBarButtonItem *leftItem2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftItemClick)];
    sencondVC2.navigationItem.leftBarButtonItem = leftItem2;
    
    sencondVC2.title = @"川菜";
    
    
    LuDishViewController *thirdVC3 = [[LuDishViewController alloc]init];
    UINavigationController *nag3 = [[UINavigationController alloc]initWithRootViewController:thirdVC3];
    UIBarButtonItem *leftItem3 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftItemClick)];
    thirdVC3.navigationItem.leftBarButtonItem = leftItem3;
    
    thirdVC3.title = @"鲁菜";
    
    
    SuDishViewController *fourthVC4 = [[SuDishViewController alloc]init];
    UINavigationController *nag4 = [[UINavigationController alloc]initWithRootViewController:fourthVC4];
    UIBarButtonItem *leftItem4 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftItemClick)];
    fourthVC4.navigationItem.leftBarButtonItem = leftItem4;
    
    fourthVC4.title = @"苏菜";
    
    
    ZheDishViewController *fifthVC5 = [[ZheDishViewController alloc]init];
    UINavigationController *nag5 = [[UINavigationController alloc]initWithRootViewController:fifthVC5];
    UIBarButtonItem *leftItem5 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftItemClick)];
    fifthVC5.navigationItem.leftBarButtonItem = leftItem5;
    
    fifthVC5.title = @"浙菜";
    self.VCDic = @{}.mutableCopy;
    [self.VCDic setValue:nag2 forKey:@"ChuanDishViewController"];
    [self.VCDic setValue:nag3 forKey:@"LuDishViewController"];
    [self.VCDic setValue:nag4 forKey:@"SuDishViewController"];
    [self.VCDic setValue:nag5 forKey:@"ZheDishViewController"];
    
    LeftViewController *leftVC = [[LeftViewController alloc]init];
    FoodsViewController *firstVC = [[FoodsViewController alloc]init];
    UINavigationController *nagVC1 = [[UINavigationController alloc]initWithRootViewController:firstVC];
    UIBarButtonItem *leftItem1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftItemClick)];
    firstVC.navigationItem.leftBarButtonItem = leftItem1;
    
    firstVC.title = @"主页";
    ChuanDishPictureViewController *sencondVC = [[ChuanDishPictureViewController alloc]init];
    UINavigationController *nagVC2 = [[UINavigationController alloc]initWithRootViewController:sencondVC];
    sencondVC.title = @"川菜";
    LuDishPictureViewController *thirdVC = [[LuDishPictureViewController alloc]init];
    UINavigationController *nagVC3 = [[UINavigationController alloc]initWithRootViewController:thirdVC];
    thirdVC.title = @"鲁菜";
    
    SuDishPictureViewController *fourthVC = [[SuDishPictureViewController alloc]init];
    UINavigationController *nagVC4 = [[UINavigationController alloc]initWithRootViewController:fourthVC];
    fourthVC.title = @"苏菜";
    ZheDishPictureViewController *fifthVC = [[ZheDishPictureViewController alloc]init];
    UINavigationController *nagVC5 = [[UINavigationController alloc]initWithRootViewController:fifthVC];
    fifthVC.title = @"浙菜";
    UITabBarController *tabBarController = [[UITabBarController alloc]init];
    tabBarController.viewControllers = @[nagVC2, nagVC3, nagVC1, nagVC4, nagVC5];
    
    tabBarController.selectedIndex = 2;
    [self.VCDic setValue:tabBarController forKey:@"tabBarController"];
    drawerViewController *drawer = [[drawerViewController alloc]initWithLeftVC:leftVC mainVC:tabBarController];
    
    [self.VCDic setValue:drawer forKey:@"drawer"];
    
    self.window.rootViewController = drawer;
    
    
    
    
    
    
    
    
    return YES;
}

- (void)leftItemClick{
    drawerViewController *drawer = (drawerViewController *)self.window.rootViewController;
    if (drawer.isOpen) {
        [drawer close];
        drawer.isOpen = NO;
    } else{
        [drawer open];
        drawer.isOpen = YES;
    }
}
- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
